fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3. int main(){
  4. double a, b, c;
  5. if(scanf("%lf %lf %lf", &a, &b, &c) ) ;
  6. if(a==0){
  7. if(b==0){
  8. printf("NO\n");
  9. }else{
  10. double x=-c/b;
  11. if(x==0) x=0;
  12. printf("%.2f\n", x);
  13. }
  14. }else{
  15. double delta=b*b-4*a*c;
  16. if(delta<0){
  17. printf("NO\n");
  18. }else if (delta==0){
  19. double x=-b/(2*a);
  20. printf("%.2f\n", x);
  21. }else{
  22. double x1=(-b+sqrt(delta))/(2*a);
  23. double x2=(-b-sqrt(delta))/(2*a);
  24. if(x1<x2){
  25. double kh=x1;
  26. x1=x2;
  27. x2=kh;
  28. }
  29. printf("%.2f %.2f\n", x1, x2);
  30. }
  31. }
  32. return 0;
  33. }
  34.  
  35.  
Success #stdin #stdout 0s 544KB
stdin
1 -2 1
stdout
1.00